//
//  CZQNaviTitleView.m
//  LoveBeer
//
//  Created by 崔正强 on 17/5/7.
//  Copyright © 2017年 崔正强. All rights reserved.
//

#import "CZQNaviTitleView.h"
#import "LoveBeer.pch"

@implementation CZQNaviTitleView

- (void)addBtns{

UIControl* scanControl = [[UIControl alloc]initWithFrame:CGRectMake(20, 25, 30, 30)];
self.scanControl = scanControl;
scanControl.backgroundColor = [UIColor colorWithWhite:120/255.0 alpha:0.4];
scanControl.layer.masksToBounds = YES;
scanControl.layer.cornerRadius = 15;
[self addSubview:scanControl];

UILabel* imgView = [[UILabel alloc]initWithFrame:CGRectMake(5, 5, 20, 20)];
self.scanImg = imgView;
imgView.text = Scan;
imgView.font =  [UIFont fontWithName:@"iconfont" size:20];
[scanControl addSubview:imgView];

UIControl* searchControl = [[UIControl alloc]initWithFrame:CGRectMake(ScreenWidth-70, 25, 30, 30)];
self.searchControl = searchControl;
searchControl.backgroundColor = [UIColor colorWithWhite:120/255.0 alpha:0.4];
searchControl.layer.masksToBounds = YES;
searchControl.layer.cornerRadius = 15;
[self addSubview:searchControl];

UILabel* searchImgView = [[UILabel alloc]initWithFrame:CGRectMake(5, 5, 20, 20)];
self.searchImg = searchImgView;
searchImgView.text = Search;
searchImgView.font = [UIFont fontWithName:@"iconfont" size:20];
[searchControl addSubview:searchImgView];


[self setupTitleView];
[self setTintalpha:0.0];

}

#pragma - 配送地址 -
- (void)setupTitleView{
    UIControl* titleView = [[UIControl alloc]initWithFrame:CGRectMake(ScreenWidth/2-100, 25, 200, 30)];
    self.titleControl = titleView;
    titleView.backgroundColor = [UIColor colorWithWhite:120/255.0 alpha:0.4];
    titleView.layer.masksToBounds = YES;
    titleView.layer.cornerRadius = 15;
    
    
    UILabel* desLabel = [[UILabel alloc]init];
    self.desLabel = desLabel;
    desLabel.text = @"配送至";
    desLabel.font = [UIFont systemFontOfSize:10];
    [titleView addSubview:desLabel];
    
    UILabel* deafultLabel = [[UILabel alloc]init];
    self.addressLabel = deafultLabel;
    deafultLabel.text = @"你在哪里呀";
    deafultLabel.font = [UIFont systemFontOfSize:15];
    [titleView addSubview:deafultLabel];
    
    UILabel* imgView = [[UILabel alloc]init];
    self.arrowImg = imgView;
    imgView.text = Rectangle;
    imgView.font = [UIFont fontWithName:@"iconfont" size:20];
    [titleView addSubview:imgView];
    
    [desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(deafultLabel.mas_leading).offset(-7);
        make.baseline.equalTo(deafultLabel);
    }];
    
    [deafultLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(titleView.mas_centerX).offset(-20);
        make.centerY.equalTo(titleView);
    }];
    
    [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(deafultLabel.mas_trailing).offset(7);
        make.centerY.equalTo(deafultLabel);
    }];
    
    [self addSubview:titleView];
}

#pragma - 设置navigationbar的颜色 -
- (void)setTintalpha:(CGFloat)alpha{
    self.coverView.backgroundColor = [UIColor colorWithRed:254/255.0 green:213/255.0 blue:48/255.0 alpha:alpha];
    UIColor* color = alpha > 0.5 ? [UIColor blackColor] :[UIColor whiteColor];
    
    self.scanImg.textColor = color;
    self.searchImg.textColor = color;
    self.desLabel.textColor = color;
    self.addressLabel.textColor = color;
    self.arrowImg.textColor = color;
    
}

@end
